package com.happy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.happy.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<UserEntity> {

    @Select (value = "select ui.id, ui.userName, ui.password, ui.nickName, ui.phone, ui.email, ui.company, ui.address, ui.sign, ui.openid, ui.sex, ui.country, ui.province, ui.city, fi.fileUrl AS headimgurl, ui.createTime, ui.changeTime, ui.isUsed from user_info ui left join file_info fi on fi.userId = ui.id and fi.type = 1 where ui.id=#{id}")
    UserEntity queryById (int id);

    @Select (value = "SELECT ui.id,ui.userName,ui.password,ui.nickName,ui.phone,ui.email,ui.company,ui.address,ui.sign,ui.openid,ui.sex,ui.country,ui.province,ui.city,fi.fileUrl AS headimgurl,ui.createTime,ui.changeTime,ui.isUsed FROM user_info ui left join file_info fi on fi.userId=ui.id limit #{offset},#{limit}")
    List<UserEntity> queryList (Integer offset, Integer limit);

}
